import * as React from 'react'
import { Route, BrowserRouter, Switch } from 'react-router-dom'
// import { Route, HashRouter, Switch } from 'react-router-dom'
import Loading from '../components/Loading'

const { lazy, Suspense } = React

const Home = lazy(() => import( /* webpackChunkName:"App" */'../pages/Home'))
const App = lazy(() => import( /* webpackChunkName:"App" */'../pages/App'))
const Company = lazy(() => import( /* webpackChunkName:"Company" */'../pages/Company'))
const AdminLayout = lazy(() => import( /* webpackChunkName:"AdminLayout" */'../pages/Admin'))

export default class AppRouter extends React.Component {
	render() {
		return (
			<BrowserRouter>
				<Suspense fallback={<Loading size="large" />}>
					<Switch>
						{/* <Route exact path="/" component={(props: any) => <Home {...props} />} /> */}
						<Route exact path="/" component={Home} />
						<Route exact path="/app" component={App} />
						<Route exact path="/company" component={Company} />
						<Route path="/admin" component={(props: any) => <AdminLayout {...props} />} />
					</Switch>
				</Suspense>
			</BrowserRouter>
		)
	}
}